package com.hongyuan.sellcoach.ui.person.view_mode;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableField;
import androidx.databinding.ObservableList;

import com.hongyuan.sellcoach.R;
import com.hongyuan.sellcoach.base.CustomViewModel;
import com.hongyuan.sellcoach.data.MyRepository;
import com.hongyuan.sellcoach.ui.person.beans.CoachDeatilsBean;

import me.tatarka.bindingcollectionadapter2.BR;
import me.tatarka.bindingcollectionadapter2.ItemBinding;

public class CoachProfileViewModel extends CustomViewModel<MyRepository> {

    public ObservableField<CoachDeatilsBean> entity = new ObservableField<>();

    //给RecyclerView添加ObservableList
    public ObservableList<CoachProfileItemViewModel> certsList = new ObservableArrayList<>();

    //给RecyclerView添加ItemBinding
    public ItemBinding<CoachProfileItemViewModel> certsBinding = ItemBinding.of(BR.viewModel, R.layout.item_coach_profile);

    public CoachProfileViewModel(@NonNull Application application, MyRepository model) {
        super(application, model);
    }


    public void setMyEntity(CoachDeatilsBean bean){
        entity.set(bean);

        if(bean.getCerts() != null && bean.getCerts().size() > 0){
            for(String b:bean.getCerts()){
                CoachProfileItemViewModel viewModel = new CoachProfileItemViewModel(this,b);
                certsList.add(viewModel);
            }
        }
    }
}
